package com.hzit.dao.service.impl;

import com.hzit.dao.entity.User;
import com.hzit.dao.mapper.UserMapper;
import com.hzit.dao.service.UserSerivce;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 类名：
 * 作者：WF
 * 功能：
 */
@Service
public class UserSerivceImpl implements UserSerivce {
	@Autowired
	private UserMapper userMapper;
	//1. 修改账户余额
	@Override
	public void updateAccount(Integer uid, int money) {
		userMapper.updateBalance(uid,money);
	}

	//2. 用户转账
	@Override
	@Transactional
	public void trans(Integer uid1, Integer uid2, Integer money) {
		//2.1 转出
		userMapper.updateBalance(uid1,money);
		String str = null;
		str.length();
		//2.2 转入
		userMapper.updateBalance(uid2,-money);
	}
}
